package com.openbravo.pos.payment;

import com.openbravo.pos.customers.CustomerInfoExt;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppProperties;
import com.openbravo.pos.forms.AppView;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIDefaults;
import javax.swing.UIManager;

public class JPaymentMagcard extends JPanel
  implements JPaymentInterface
{
  private PaymentPanel m_cardpanel;
  private PaymentGateway m_paymentgateway;
  private JPaymentNotifier m_notifier;
  private String transaction;
  private JPanel jPanel1;
  private JTextArea jlblMessage;

  public JPaymentMagcard(AppView paramAppView, JPaymentNotifier paramJPaymentNotifier)
  {
    initComponents();
    this.m_notifier = paramJPaymentNotifier;
    this.m_paymentgateway = PaymentGatewayFac.getPaymentGateway(paramAppView.getProperties());
    if (this.m_paymentgateway == null)
    {
      this.jlblMessage.setText(AppLocal.getIntString("message.nopaymentgateway"));
    }
    else
    {
      this.m_cardpanel = PaymentPanelFac.getPaymentPanel(paramAppView.getProperties().getProperty("payment.magcardreader"), paramJPaymentNotifier);
      add(this.m_cardpanel.getComponent(), "Center");
      this.jlblMessage.setText(null);
    }
  }

  public void activate(CustomerInfoExt paramCustomerInfoExt, double paramDouble, String paramString)
  {
    this.transaction = paramString;
    if (this.m_cardpanel == null)
    {
      this.jlblMessage.setText(AppLocal.getIntString("message.nopaymentgateway"));
      this.m_notifier.setStatus(false, false);
    }
    else
    {
      this.jlblMessage.setText(null);
      this.m_cardpanel.activate(this.transaction, paramDouble);
    }
  }

  public PaymentInfo executePayment()
  {
    this.jlblMessage.setText(null);
    PaymentInfoMagcard localPaymentInfoMagcard = this.m_cardpanel.getPaymentInfoMagcard();
    this.m_paymentgateway.execute(localPaymentInfoMagcard);
    if (localPaymentInfoMagcard.isPaymentOK())
      return localPaymentInfoMagcard;
    this.jlblMessage.setText(localPaymentInfoMagcard.getMessage());
    return null;
  }

  public Component getComponent()
  {
    return this;
  }

  public void setTransaction(String paramString)
  {
    this.transaction = paramString;
  }

  private void initComponents()
  {
    this.jPanel1 = new JPanel();
    this.jlblMessage = new JTextArea();
    setLayout(new BorderLayout());
    this.jlblMessage.setBackground(UIManager.getDefaults().getColor("Label.background"));
    this.jlblMessage.setEditable(false);
    this.jlblMessage.setLineWrap(true);
    this.jlblMessage.setWrapStyleWord(true);
    this.jlblMessage.setFocusable(false);
    this.jlblMessage.setPreferredSize(new Dimension(300, 72));
    this.jlblMessage.setRequestFocusEnabled(false);
    this.jPanel1.add(this.jlblMessage);
    add(this.jPanel1, "South");
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.payment.JPaymentMagcard
 * JD-Core Version:    0.6.0
 */